import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd());
  console.log(mode, env);
  // const base = `/${env.VITE_ROOT}`;
  // const baseAPI = `^/(?!${env.VITE_ROOT})`;
  return {
    plugins: [vue()],
    // base,
    resolve: {
      alias: {
        '@': '/src',
      },
    },
    server: {
      proxy: {
        '/api': {
          target: `https://${env.VITE_IP}${env.VITE_BASE_API}`,
          changeOrigin: true,
          secure: false,
        },
      },
    },
  };
});
